<template>
	<h1>App...</h1>
	<ul>
		<li v-for="(value, key) in person" :key="key">{{ key }}--{{ value }}</li>
	</ul>
	<ul>
		<li v-for="(person, index) in persons" :key="index">
			{{ person }}
		</li>
	</ul>
	<button @click="update">update</button>
</template>

<script>
export default {
	name: 'App',
	data() {
		// vue2 Object.defineProperty实现响应式，问题新增加的属性数据，不是响应式
		// 解决：this.$set
		// vue3 proxy实现响应式，所有data数据都是响应式
		return {
			person: {
				name: 'jack',
				age: 18,
			},
			persons: [{ name: 'jack', age: 18 }],
		}
	},
	methods: {
		update() {
			// this.person.sex = '男'
			this.persons[1] = { name: 'rose', age: 18 }
		},
	},
}

// This starter template is using Vue 3 experimental <script setup> SFCs
// Check out https://github.com/vuejs/rfcs/blob/script-setup-2/active-rfcs/0000-script-setup.md
</script>

<style>
#app {
	font-family: Avenir, Helvetica, Arial, sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-align: center;
	color: #2c3e50;
	margin-top: 60px;
}
</style>
